from elasticsearch_dsl import DocType, Keyword, Text
from elasticsearch_dsl.connections import connections

connections.create_connection(hosts=['localhost'])

class NewsType(DocType):
    title = Keyword  # title不作分词
    content = Text(analyzer='ik_max_word')  #内容使用ik最大分词

    class Meta:
        index = 'baidunews'  # 索引名
        doc_type = 'news'    # 表名

if __name__=='__main__':
    NewsType.init()